function throttle(fn, delay) {
  var prev = new Date.getTime();
  return function(){
    var now = new Date().getTime()
    if(now - prev >= delay){
      fn.apply(this, arguments)
      prev = new Date.getTime();
    }
  }
}

function throttle(fn, delay) {
  var timer = null
  return function(){
    if(!timer){
      timer = setTimeout(() =>{
        fn.apply(this, arguments)
        timer = null
      }, delay)
    }
  }
}